package com.newtouch.avmarketing.mgr.modules.avmarkrting.api;

import com.newtouch.avmarketing.mgr.modules.avmarkrting.model.Result;
import com.newtouch.avmarketing.mgr.modules.avmarkrting.model.ResultCodes;
import com.newtouch.avmarketing.mgr.modules.avmarkrting.service.ReadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.File;

@RestController
@Api(tags ="06 双录节点：文字转语音")
@Slf4j
@RequestMapping("/api/readtext")
public class ReadServiceApi {

    @Resource
    private ReadService readService;

    @ApiOperation("文字转语音")
    @PostMapping("/readText")
    public Result readText(@RequestParam("file") File file){
        try {
            readService.readText(file);
            return Result.of(ResultCodes.SUCCESS_CODE,"播放成功! ");
        }catch (Exception e){
            log.error("错误信息：" +e);
        }
        return Result.of(ResultCodes.ERROR_CODE,"播放失败! ");
    }

//    @ApiOperation("文字转语音并播放")
//    @PostMapping("/textToSpeech")
//    public Result textToSpeech(@RequestBody DoubleConfiguration doubleConfiguration){
//        try {
//            readService.textToSpeech(doubleConfiguration.getId());
//            return Result.of(ResultCodes.SUCCESS_CODE,"播放成功! ");
//        }catch (Exception e){
//            log.error("错误信息：" +e);
//        }
//        return Result.of(ResultCodes.ERROR_CODE,"播放失败! ");
//    }
}
